From 51e3c2b39a56e85e75f467f7b5630017f0f2da73 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Wed, 7 Sep 2005 10:04:54 +0000 Subject: [PATCH] Be more sensitive to losing sync with platform timer. Signed-off-by: Keir Fraser --- xen/arch/x86/time.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 81100e7a1c..7e972bea94 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -791,6 +791,13 @@ static void local_time_calibration(void *unused) stime_elapsed64 = curr_master_stime - prev_master_stime; tsc_elapsed64 = curr_tsc - prev_tsc; + /* + * Weirdness can happen if we lose sync with the platform timer. + * We could be smarter here: resync platform timer with local timer? + */ + if ( ((s64)stime_elapsed64 < (EPOCH / 2)) ) + goto out; + /* * Calculate error-correction factor. This only slows down a fast local * clock (slow clocks are warped forwards). The scale factor is clamped @@ -854,6 +861,7 @@ static void local_time_calibration(void *unused) cpu_time[cpu].stime_local_stamp = curr_local_stime; cpu_time[cpu].stime_master_stamp = curr_master_stime; + out: set_ac_timer(&cpu_time[cpu].calibration_timer, NOW() + EPOCH); if ( cpu == 0 ) -- 2.30.2